﻿Imports Microsoft.DirectX
Imports Microsoft.DirectX.Direct3D
Imports System.Drawing
Imports System.Drawing.Imaging

Public Class Schriftengine
    Structure Font
        Public Sub New(ByVal neuSchrift As Direct3D.Font, ByVal neuSchriftart As String)
            Schrift = neuSchrift
            Schriftart = neuSchriftart
        End Sub
        Dim Schrift As Direct3D.Font
        Public Function GetFont() As Direct3D.Font
            Return Schrift
        End Function
        Dim Schriftart As String
        Public Function GetSchriftart() As String
            Return Schriftart
        End Function
    End Structure



    Enum Schriftarten
        Arial
        Century
        Elephant
    End Enum
    Public Shared Sprite2 As Direct3D.Sprite
    Public Shared Texte() As ObjektText = {}
    Public Shared Fonts() As Font = {}
    Public Sub New()
        Sprite2 = New Direct3D.Sprite(Grafikengine.Grafikkarte)
    End Sub
    Public Shared Function Malen() As Boolean
        Grafikengine.Sprite.End()
        Sprite2.Begin(SpriteFlags.AlphaBlend)
        If Texte.Length > 0 Then
            For I = 0 To Texte.Length - 1
                Texte(I).Malen(Sprite2)
            Next
        End If
        Sprite2.End()
        Grafikengine.Sprite.Begin(SpriteFlags.AlphaBlend)
    End Function
    Public Shared Sub Schriftlöschen(ByVal Text As Integer)
        Texte(Text) = Texte(Texte.Length - 1)
        Array.Resize(Texte, Texte.Length - 1)
    End Sub
    Public Shared Sub Schrifterstellen(ByVal neuText() As String, ByVal X As Integer, ByVal Y As Integer, ByVal neueFarbe() As Color, ByVal neueSchriftart As String, ByVal neuSchriftgröße As Integer, ByVal Stil As System.Drawing.FontStyle, Optional ByVal neuSchreiben As Boolean = False)
        Array.Resize(Texte, Texte.Length + 1)
        Texte(Texte.Length - 1) = New ObjektText(neuText, X, Y, neueFarbe, neueSchriftart, neuSchriftgröße, Stil, neuSchreiben)
    End Sub
    Public Shared Sub DrawText(ByVal Text As ObjektText)
        Grafikengine.Sprite.End()
        SyncLock Sprite2
            Schriftengine.Sprite2.Begin(SpriteFlags.AlphaBlend)
            Text.Malen(Schriftengine.Sprite2)
            Schriftengine.Sprite2.End()
        End SyncLock
        Grafikengine.Sprite.Begin(SpriteFlags.AlphaBlend)
    End Sub
End Class
